package com.spa.application.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.spa.infrastructure.util.CurrencyUtils;

/**
 * excel导出转换金额分->元转换
 */
public class AmountConverter implements Converter<String> {

    @Override
    public Class<?> supportJavaTypeKey() {
        return String.class;
    }
    @Override
    public WriteCellData<String> convertToExcelData(String value, ExcelContentProperty contentProperty,
            GlobalConfiguration globalConfiguration) {
        if(value == null || value.equals("")){
            return new WriteCellData<String>((String) null);
        }
        value = CurrencyUtils.fenToYuan(Integer.valueOf(value)).toString();
        return new WriteCellData<String>(value);
    }

}
